package com.bean;
import com.dao.*;


public class Composition implements SqlObject{
private int id;
private String name;
private double energy;
private double protein;
private double fat;
private double sugar;
private double Ca;
private double Fe;
private double VA;
private double VB1;
private double VB2;
private double VC;
private double VD;
private double VE;

public Composition(int id, String name, double energy, double protein, double fat, double sugar, double ca, double fe,
		double vA, double vB1, double vB2, double vC, double vD, double vE) {
	super();
	this.id = id;
	this.name = name;
	this.energy = energy;
	this.protein = protein;
	this.fat = fat;
	this.sugar = sugar;
	Ca = ca;
	Fe = fe;
	VA = vA;
	VB1 = vB1;
	VB2 = vB2;
	VC = vC;
	VD = vD;
	VE = vE;
}

public Composition(){}

public int getId() {
	return id;
}

public void setId(int id) {
	this.id = id;
}

public String getName() {
	return name;
}

public void setName(String name) {
	this.name = name;
}

public double getEnergy() {
	return energy;
}

public void setEnergy(double energy) {
	this.energy = energy;
}

public double getProtein() {
	return protein;
}

public void setProtein(double protein) {
	this.protein = protein;
}

public double getFat() {
	return fat;
}

public void setFat(double fat) {
	this.fat = fat;
}

public double getSugar() {
	return sugar;
}

public void setSugar(double sugar) {
	this.sugar = sugar;
}

public double getCa() {
	return Ca;
}

public void setCa(double ca) {
	Ca = ca;
}

public double getFe() {
	return Fe;
}

public void setFe(double fe) {
	Fe = fe;
}

public double getVA() {
	return VA;
}

public void setVA(double vA) {
	VA = vA;
}

public double getVB1() {
	return VB1;
}

public void setVB1(double vB1) {
	VB1 = vB1;
}

public double getVB2() {
	return VB2;
}

public void setVB2(double vB2) {
	VB2 = vB2;
}

public double getVC() {
	return VC;
}

public void setVC(double vC) {
	VC = vC;
}

public double getVD() {
	return VD;
}

public void setVD(double vD) {
	VD = vD;
}

public double getVE() {
	return VE;
}

public void setVE(double vE) {
	VE = vE;
}

@Override
public String toString() {
	return "Composition [id=" + id + ", name=" + name + ", energy=" + energy + ", protein=" + protein + ", fat=" + fat
			+ ", sugar=" + sugar + ", Ca=" + Ca + ", Fe=" + Fe + ", VA=" + VA + ", VB1=" + VB1 + ", VB2=" + VB2
			+ ", VC=" + VC + ", VD=" + VD + ", VE=" + VE + "]";
}

public Composition add(Composition obj){
	if(obj!=null){
	id=-1;
	energy+=obj.energy;
	protein+=obj.protein;
	fat+=obj.fat;
	sugar+=obj.sugar;
	Ca+=obj.Ca;
	Fe+=obj.Fe;
	VA+=obj.VA;
	VB1+=obj.VB1;
	VB2+=obj.VB2;
	VC+=obj.VC;
	VD+=obj.VD;
	VE+=obj.VE;
}
	return this;
	}

public void multiply(double i){
	name="COUNT";
	energy*=i;
	protein*=i;
	fat*=i;
	sugar*=i;
	Ca*=i;
	Fe*=i;
	VA*=i;
	VB1*=i;
	VB2*=i;
	VC*=i;
	VD*=i;
	VE*=i;
}

public void round(){//去除double类型本身容易出现超长小数位的bug
	energy=Math.round(energy*100)/10000.00;
	protein=Math.round(protein*100)/10000.00;
	fat=Math.round(fat*100)/10000.00;
	sugar=Math.round(sugar*100)/10000.00;
	Fe=Math.round(Fe*100)/10000.00;
	Ca=Math.round(Ca*100)/10000.00;
	VB1=Math.round(VB1*100)/10000.00;
	VB2=Math.round(VB2*100)/10000.00;
	VC=Math.round(VC*100)/10000.00;
	VD=Math.round(VD*100)/10000.00;
	VE=Math.round(VE*100)/10000.00;
}
}
